﻿#region Apache License Version 2.0
/*----------------------------------------------------------------

Copyright 2019 Suzhou Senparc Network Technology Co.,Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.

Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md

----------------------------------------------------------------*/
#endregion Apache License Version 2.0

/*----------------------------------------------------------------
    Copyright (C) 2020 Senparc
    
    文件名：IMessageHandlerWithContext.cs
    文件功能描述：具有上下文的 MessageHandler 接口


    创建标识：Senparc - 20181022

    修改标识：Senparc - 20190914
    修改描述：（V5.0）v0.8.0 提供支持分布式缓存的消息上下文（MessageContext）
    
    修改标识：Senparc - 20190914
    修改描述：添加 GettCurrentMessageContext() 方法，将 CurrentMessageContext 只读属性标记为过期

----------------------------------------------------------------*/


/*
 * V3.2
 * V4.0 添加异步方法
 * v5.0 支持分布式缓存
 */

using Senparc.NeuChar.Context;
using Senparc.NeuChar.Entities;
using System;
using System.Threading.Tasks;

namespace Senparc.NeuChar.MessageHandlers
{
    /// <summary>
    /// 具有上下文的 MessageHandler 接口
    /// </summary>
    /// <typeparam name="TMC"></typeparam>
    /// <typeparam name="TRequest"></typeparam>
    /// <typeparam name="TResponse"></typeparam>
    public interface IMessageHandlerWithContext<TMC, TRequest, TResponse> : IMessageHandler<TRequest, TResponse>
        where TMC : class, IMessageContext<TRequest, TResponse>, new()
        where TRequest : class, IRequestMessageBase
        where TResponse : class, IResponseMessageBase
    {
        /// <summary>
        /// 全局消息上下文
        /// </summary>
        GlobalMessageContext<TMC, TRequest, TResponse> GlobalMessageContext { get; }
        /// <summary>
        /// 当前用户消息上下文
        /// </summary>
        [Obsolete("请使用 GettMessageContext() 获取信息！")]
        TMC CurrentMessageContext { get; }
        /// <summary>
        /// 当前用户消息上下文
        /// </summary>
        /// <returns></returns>
        Task<TMC> GetCurrentMessageContext();


    }
}
